import numpy as np
import matplotlib.pyplot as plt
#支持中文
plt.rcParams['font.family'] = ['sans-serif']
plt.rcParams['font.sans-serif'] = ['SimHei']
# 数据准备
sizes = [15, 30, 45, 10]
labels = ['A', 'B', 'C', 'D']
explode = (0, 0.1, 0, 0)  # 突出显示第二块
# 创建图形
plt.figure(figsize=(8, 6))
plt.pie(sizes, 
        explode=explode,
        labels=labels,
        autopct='%1.1f%%',
        shadow=True,
        startangle=90,
        colors=['#ff9999','#66b3ff','#99ff99','#ffcc99'])
plt.title("市场份额饼图")
plt.axis('equal')  # 保证饼图是圆形
plt.show()
